[PerlMapToStorageHandler] Basic URI to File translation example

PerlMapToStorageHandler

I would like to use the PerlMapToStorageHandler to translate a URI file =
request into a Filesystem file request. I have a couple functions to =
check and see if a file exists, and if not, then copy it from a remote =
server locally before allowing the request to go to the next phase.



Basic gist of what I want to handle in the PerlMapToStorageHandler is:

1) Client makes a request to server for /package_20.zip

2) My handler:
gets the filename from the URI (no problem here)
maps the filename to a real file on the file system
checks to make sure the file exists

File does not exist:
copy file from another location to =
destination
properly MapToStorage, and let the next =
phase take place
=09


File exists:
properly MapToStorage, and let the next =
phase take place

3) Client receives file=
Robert Smith [ Sa, 17 April 2010 18:32 ] [ ID #2039236 ]

Re: [PerlMapToStorageHandler] Basic URI to File translation example

On Saturday 17 April 2010 18:32:13 Robert Smith wrote:
> PerlMapToStorageHandler
>
> I would like to use the PerlMapToStorageHandler to translate a URI file
> request into a Filesystem file request. I have a couple functions to che=
ck
> and see if a file exists, and if not, then copy it from a remote server
> locally before allowing the request to go to the next phase.
>
>
>
> Basic gist of what I want to handle in the PerlMapToStorageHandler is:
>
> 1) Client makes a request to server for /package_20.zip
>
> 2) My handler:
> gets the filename from the URI (no problem here)
> maps the filename to a real file on the file system
> checks to make sure the file exists
>
> File does not exist:
> copy file from another location to destination
> properly MapToStorage, and let the next phase take place
>
>
>
> File exists:
> properly MapToStorage, and let the next phase take place
>
> 3) Client receives file
>
The only thing to watch out here is either to fill in $r->finfo+$r->path_in=
fo
correctly or to return DECLINED and have the core m2s handler done it. $r-
>filename is normally set by the translation handler. The core trans handle=
r
does just $r->document_root.$r->uri. You can change that if you need. The c=
ore
m2s handler also looks for .htaccess and applies <Directory> and <Files>
blocks. So better to return DECLINED from your handler. Otherwise the AAA
phases might not do what you want.

Have you thought about mod_proxy+mod_cache to solve the problem?

Torsten Förtsch

=2D-
Need professional modperl support? Hire me! (http://foertsch.name)

Like fantasy? http://kabatinte.net
torsten.foertsch [ Sa, 17 April 2010 19:22 ] [ ID #2039237 ]
Webserver » gmane.comp.apache.mod-perl » [PerlMapToStorageHandler] Basic URI to File translation example

Vorheriges Thema: mod_perl in larger scale environments
Nächstes Thema: modperl and comet?